package cn.school.controller.studyManage;

import cn.school.common.api.CommonResult;
import cn.school.studyManage.dto.StudentBehaviorCfgClassDTO;
import cn.school.studyManage.service.StudentBehaviorCfgClassService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("student/behavior/cfg/class")
public class StudentBehaviorCfgClassController {

    @Autowired
    StudentBehaviorCfgClassService cfgClassService;

    @ApiOperation("createOrUpdate => 创建或更新班级配置关联表")
    @PostMapping("/createOrUpdateCfgClassBatch")
    public CommonResult createOrUpdateCfgClassBatch(@RequestBody StudentBehaviorCfgClassDTO dto){
        boolean flag = cfgClassService.createOrUpdateCfgClassBatch(dto);
        if(flag){
            return CommonResult.success();
        }
        return CommonResult.failed("failed");
    }

    @ApiOperation("find => 通过配置id查找班级")
    @GetMapping("/findClassByCfgId/{cfgId}")
    public CommonResult findClassByCfgId(@PathVariable("cfgId")Long cfgId){
        return CommonResult.success(cfgClassService.findClassByCfgId(cfgId));
    }

    @ApiOperation("find => 通过班级id查找配置")
    @GetMapping("/findCfgByClassId/{classId}")
    public CommonResult findCfgByClassId(@PathVariable("classId")Long classId){
        return CommonResult.success(cfgClassService.findCfgByClassId(classId));
    }

}
